package day19s;

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String a= in.nextLine();
            String b= in.nextLine();
            boolean[][] dp=new boolean[a.length()+1][b.length()+1];
            dp[0][0]=true;
            for(int i=1;i<=b.length();i++){
                for(int j=1;j<=a.length();j++){
                    if(a.charAt(j-1)==b.charAt(i-1)||a.charAt(j-1)=='?'){
                        dp[i][j]=dp[i-1][j-1];
                    }
                    if(a.charAt(j-1)=='*'){
                        dp[i][j]=dp[i-1][j-1];
                    }
                }
            }
             System.out.println(dp[a.length()][b.length()]);
        }
    }
}
